#include<bits/stdc++.h>
using namespace std;

int n, a[100010], ans, c[100010], m, ma;

inline void read(int& n){
    n = 0;
    int f = 1;
    char c;
    for(c = getchar(); c > '9' || c < '0'; c = getchar())
        if(c == '-')
            f = -1;
    for(; c >= '0' && c <= '9'; c = getchar())
        n = n * 10 + c - '0';
    n *= f;
}

int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    read(n);
    for(int i = 2; i <= n + 1; i++)
        read(a[i]);
    sort(a + 2, a + n + 2);
    for(int i = 2; i <= n + 1; i++)
        if(a[i] != a[i - 1])
            a[i - 1] = a[i - 2] + 1, m++;
        else
            a[i - 1] = a[i - 2];
    for(int i = 1; i <= n; i++)
        c[a[i]]++;
    for(int i = 2; i <= m; i++)
        ma = max(ma, c[i - 1]), ans += min(c[i], ma);
    printf("%d", n - ans);
}
